package simplyrugby.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import simplyrugby.entity.Place;
import simplyrugby.entity.Place;
import simplyrugby.mapper.PlaceMapper;
import simplyrugby.service.PlaceService;

@Service
public class PlaceServiceImpl extends ServiceImpl<PlaceMapper, Place> implements PlaceService{

    @Override
    public Page<Place> list(Integer pageNum, Integer pageSize, Place team) {
        LambdaQueryWrapper<Place> wrapper = Wrappers.lambdaQuery(Place.class)
                .eq(!ObjectUtils.isEmpty(team.getId()), Place::getId, team.getId())
                .like(!ObjectUtils.isEmpty(team.getName()), Place::getName, team.getName());

        Page<Place> page = new Page<>(pageNum, pageSize);
        this.page(page, wrapper);
        return page;
    }
}




